package muilty_thread.thread_local;

public class ThreadLocalExample {


    public static class MyRunnable implements Runnable{
        private ThreadLocal<Integer> threadLocal = new ThreadLocal<>();



        @Override
        public void run() {
            threadLocal.set((int) (Math.random() * 100D));

            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            System.out.println(threadLocal.get());


        }
    }


    public static void main(String[] args) throws InterruptedException {

        MyRunnable run = new MyRunnable();

        Thread thread1 = new Thread(run);
        Thread thread2 = new Thread(run);
        thread1.start();
        thread2.start();
        thread1.join();
        thread2.join();
    }

}
